<template>
  <div>
    <div class="header">
      <van-image
        round
        width="70"
        height="70"
        fit="cover"
        :src="userInfo.photo"
      />
      <h2>
        {{userInfo.name}}<br />
        <van-tag color="#fff" text-color="#009afb">{{userInfo.birthday}}</van-tag>
      </h2>
    </div>

    <van-row gutter="20">
      <van-col span="8"
        ><van-icon color="#2eadff" name="newspaper-o" /><span
          >我的作品</span
        ></van-col
      >
      <van-col span="8"
        ><van-icon color="#ff4f31" name="like-o" /><span
          >我的收藏</span
        ></van-col
      >
      <van-col span="8"
        ><van-icon color="#ffa893" name="tosend" /><span
          >阅读历史</span
        ></van-col
      >
    </van-row>
    <van-cell-group>
      <van-cell title="编辑资料" icon="edit"  is-link @click="$router.push('/edit')"/>
      <van-cell title="小智同学" icon="chat-o"  is-link />
      <van-cell title="系统设置" icon="setting-o"  is-link />
      <van-cell title="退出登录" icon="warning-o"  is-link @click="logout"/>
    </van-cell-group>
  </div>
</template>

<script>
import {  removeToken } from '@/utils/token.js'
import { getUserInfo } from './user.js'
export default {
  name: 'user',
  data() {
    return {
      userInfo:{}
    }
  },
  created(){
    getUserInfo()
    .then(res=>{
      console.log(res);
      this.userInfo=res.data.data
      this.$store.commit('updateUserInfo',res.data.data)
    })
  },
  methods: {
    logout(){
      removeToken()
      this.$toast.success('退出成功');
      this.$router.push({path:'/login'})
    }
  },
}
</script>

<style lang="less">
.header {
  height: 100px;
  background-color: #009afb;
  display: flex;
  align-items: center;
  .van-image {
    padding: 0 15px;
  }
  h2 {
    font-size: 18px;
    font-weight: 400;
    color: #fff;
  }
}
.van-row {
  .van-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    span {
      font-size: 14px;
      padding: 12px 0;
    }
  }
}
</style>
